package com.niiwoo.civet.scheduler.trigger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.trade.service.creditor.CreditorTransferConfirmDubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;


/**
 * 债转确认相关任务
 * @author liaojunjun
 *
 */
@Component
public class CreditorTransferConfirmJobTrigger {
    private static final Logger logger = LoggerFactory.getLogger(CreditorTransferConfirmJobTrigger.class);

    @Reference(version = "1.0.0")
    private CreditorTransferConfirmDubboService creditorTransferConfirmDubboService;

    @Scheduled(cron = "${creditorsale.transfer-confirm-result-query}")
    public void bankCreditorTransferConfirmResultQueryJob() {
        logger.info("银行债转确认结果查询...");
        CompletableFuture.runAsync(() -> creditorTransferConfirmDubboService.bankCreditorTransferConfirmResultQueryJob());
    }

    @Scheduled(cron = "${creditorsale.transfer-confirm-failed}")
    public void bankCreditorTransferConfirmFailedJob() {
        logger.info("银行债转确认失败任务...");
        CompletableFuture.runAsync(() -> creditorTransferConfirmDubboService.bankCreditorTransferConfirmFailedJob());
    }

    @Scheduled(cron = "${creditorsale.transfer-confirm-accounting}")
    public void accountingStatusJob() {
        logger.info("记账任务...");
        CompletableFuture.runAsync(() -> creditorTransferConfirmDubboService.accountingStatusJob());
    }

    @Scheduled(cron = "${creditorsale.transfer-confirm-accounting}")
    public void sellerInvestPrizeStatusJob() {
        logger.info("债转出让人投资红包处理任务...");
        CompletableFuture.runAsync(() -> creditorTransferConfirmDubboService.sellerInvestPrizeStatusJob());
    }


    @Scheduled(cron = "${creditorsale.transfer-confirm-accounting}")
    public void sellerProjectActivityRaiseInterestStatusJob() {
        logger.info("债权出让人标的加息处理任务...");
        CompletableFuture.runAsync(() -> creditorTransferConfirmDubboService.sellerProjectActivityRaiseInterestStatusJob());
    }
}